package com.czk.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.czk.pojo.User;
import com.czk.service.UserService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Value;

/**
 * 版本号；不同的实现可以指定版本，根据服务提供者的实现版本号来进行选择
 *
 * @Author:ChenZhangKun
 * @Date: 2021/3/23 16:18
 */
@Service(interfaceClass = UserService.class, version = "2.0")
public class UserServiceImpl2 implements UserService {
    @Value("${server.port}")
    private Integer port;

    @Override
    @HystrixCommand
    public User getUserByName(String username) {
        if (Math.random() > 0.5) {
            throw new RuntimeException("异常");
        }
        return new User(username + " " + port, 27, "nv");
    }
}
